//
//  Network+Upload.h
//  YanXiuWang
//
//  Created by 慧趣小歪 on 16/12/14.
//  Copyright © 2016年 小分队. All rights reserved.
//

#import "Network.h"

//@interface DataStream : NSInputStream
//
//@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
////@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts;
////@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator;
////@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart;
//@property (readwrite, nonatomic, strong) NSOutputStream *outputStream;
//@property (readwrite, nonatomic, strong) NSMutableData *buffer;
//
//
//@end
@class RequestUpload;
@protocol UploadFormData;

typedef void (^UPLOAD_FILE)(id<UploadFormData> _Nonnull formData);
typedef id<UploadFormData> _Nonnull (^UPLOAD_FORM_TEXT)(NSString * _Nonnull string);
typedef id<UploadFormData> _Nonnull (^UPLOAD_FORM_DATA)(NSData * _Nonnull data);
typedef RequestUpload * _Nonnull (^UPLOAD_TEXT)(NSString * _Nonnull string);

@interface NetworkManager (Upload)

- (nonnull RequestUpload *)upload:(UPLOAD_FILE _Nonnull)formDataBlock;

@property (nonatomic, readonly, nonnull) NSURLSession *uploadSession;

@end

@interface RequestUpload : RequestNormal

/*  上传到指定URL @param url(String)  */
@property (nonatomic, readonly, nonnull) UPLOAD_TEXT to;
/*  上传到指定URL @param url(String)  */
@property (nonatomic, readonly, nonnull) NET_PROGRESS progress;

@end

/// 必须先使用 data 或 path 其他参数在后面
@protocol UploadFormData

/*  上传的二进制 @param data(NSData)  */
@property (nonatomic, readonly, nonnull) UPLOAD_FORM_DATA data;
/*  上传文件路径 @param path(String)  */
@property (nonatomic, readonly, nonnull) UPLOAD_FORM_TEXT path;
/*  上传的参数名 @param text(String)  */
@property (nonatomic, readonly, nonnull) UPLOAD_FORM_TEXT name;
/*  上传的文件名 @param text(String)  */
@property (nonatomic, readonly, nonnull) UPLOAD_FORM_TEXT fileName;
/*  上传文件类型 @param text(String)  */
@property (nonatomic, readonly, nonnull) UPLOAD_FORM_TEXT mimeType;

@end

